--
-- @Author:      feilong
-- @DateTime:    2019-12-19 15:05:48
-- @Description: 消息的处理

local skynet = require "skynet"
local game_def = require("game_def")

local MessageHandler = class("MessageHandler")

---------------------------------------------------------
-- Private
---------------------------------------------------------
function MessageHandler:ctor(message_dispatch)

	self.message_dispatch = message_dispatch	

	self:register()
end

--注册本服务里的消息
function MessageHandler:register()
	--启动
	self.message_dispatch:registerSelf('start', handler(self,self.start))

	self.message_dispatch:registerSelf('test', handler(self,self.test))

	self.message_dispatch:registerSelf('on_activity_end', handler(self,self.on_activity_end))
	self.message_dispatch:registerSelf('get_player_activity_data', handler(self,self.get_player_activity_data))
	self.message_dispatch:registerSelf('add_act_play_count', handler(self,self.add_act_play_count))
	self.message_dispatch:registerSelf('act_add_login_day', handler(self,self.act_add_login_day))
	self.message_dispatch:registerSelf('act_add_day_online_time', handler(self,self.act_add_day_online_time))
	self.message_dispatch:registerSelf('take_task_act_award', handler(self,self.take_task_act_award))
	self.message_dispatch:registerSelf('set_gm_time', handler(self,self.set_gm_time))





end



------------------------------------------------------------------
--cmd
------------------------------------------------------------------
function MessageHandler:start()
	print("______task_start_______")
	self.config = global.config	


end

function MessageHandler:test()

end


function MessageHandler:on_activity_end(is_force)
    on_activity_end(is_force)
end

function MessageHandler:get_player_activity_data(uid)
    print("get_player_activity_data========bb",uid)
    local ret_data = skynet.call(".act_userdata_inter","lua","get_player_activity_data",uid,self_act_id)
    if not ret_data then
        return false
    end

    return ret_data
end

function MessageHandler:add_act_play_count(uid,count)
    print("add_act_play_count=========",uid,count)
    skynet.send(".act_userdata_inter","lua","act_add_play_times",uid,self_act_id,count)
end

function MessageHandler:act_add_login_day(uid,count)
    print("act_add_login_day=========",uid,count)
    skynet.send(".act_userdata_inter","lua","act_add_login_day",uid,self_act_id,count)
end

function MessageHandler:act_add_day_online_time(uid,online_seconds)
    print("act_add_day_online_time=========",uid,online_seconds)
    skynet.send(".act_userdata_inter","lua","act_add_day_online_time",uid,self_act_id,online_seconds)
end

function MessageHandler:take_task_act_award(uid,act_id,task_type,target_process,continue_time)
    print("take_task_act_award=========",uid,act_id,task_type,target_process,continue_time)
    local ok = skynet.call(".act_userdata_inter","lua","take_task_act_award",uid,act_id,task_type,target_process,continue_time)
    if not ok then
        return false
    end

    return true
end

function MessageHandler:set_gm_time(data)
    gm_time = data
    return true
end
